import time

from selenium import webdriver

from ..exception.TestException import TestException
from ..common.ui.Selector import Selector
import pytest

from .Tabs import Tabs


def test_no_datasource_set():
    browser = webdriver.Chrome()
    browser.maximize_window()
    browser.get("https://fish.iwhalecloud.com/fish-desktop/examples/tabs/index.html")
    time.sleep(2)
    try:
        mulitSelect = Tabs(browser, 'tabs', Selector.ID)
        mulitSelect.click("Third")
        # time.sleep(2)
        mulitSelect.click("First")
        # time.sleep(2)
        mulitSelect.click("Second")
        # time.sleep(2)
    finally:
        browser.close()


def test_select_data_not_exist():
    browser = webdriver.Chrome()
    browser.maximize_window()
    browser.get("https://fish.iwhalecloud.com/fish-desktop/examples/tabs/index.html")
    time.sleep(2)
    try:
        mulitSelect = Tabs(browser, 'tabs', Selector.ID)
        with pytest.raises(TestException):
            mulitSelect.click("FiveXXXXXXXXXXXXXXXXXXXX")

    finally:
        browser.close()


if __name__ == '__main__':
    pytest.main(['-s','Tabs_test.py'])
